package com.sdx.console.spread.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ibeetl.admin.core.annotation.Dict;
import com.ibeetl.admin.core.entity.BaseEntity;
import com.sdx.common.utils.Utils;
import lombok.Data;
import org.beetl.sql.core.annotatoin.AssignID;
import org.beetl.sql.core.annotatoin.Table;

import java.util.Date;

/**
 * @ClassName ChannelSet
 * @Description
 * @Author kangbin
 * @Date 2020/3/24 15:20
 */
@Data
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@Table(name = "coredb.channel_set")
public class Channel extends BaseEntity {

    @AssignID
    private String channelCode ;

    @AssignID
    private Integer tenantId;

    //渠道名称
    private String channelName;

    //渠道类型 a、本公司，b、区域、c、合作伙伴
    @Dict(type="channel_type")
    private String channelType;

    private Integer divideRate;

    private Integer orgId;

    private Date createdTime;

    private Integer choicePrice;

    private Long commissionMoneyStart;
    private Long commissionMoneyEnd;

    private Integer totalStart;
    private Integer totalEnd;

    private Long totalMoneyStart;
    private Long totalMoneyEnd;

    private String createTimeQuery;

    private Date createTimeStart;

    private Date createTimeEnd;
    public String getCreateTimeQuery(){
        return  createTimeQuery;
    }
    public void setCreateTimeQuery(String createTimeQuery ){
        this.createTimeQuery = createTimeQuery;
        Date[] timePair = Utils.parseQueryTime(createTimeQuery);
        if (timePair!=null && timePair[0]!=null) {
            this.createTimeStart = timePair[0];
        }
        if (timePair!=null && timePair.length==2 && timePair[1]!=null) {
            this.createTimeEnd = timePair[1];
        }
    }


}
